<template>
  <div>
    <x-header>查找项目</x-header>
    <search
       @result-click="resultClick"
       @on-change="getResult"
       :results="results"
       v-model="value"
       position="absolute"
       auto-scroll-to-top top="46px"
       @on-submit="onSubmit"
       ref="search"></search>
     <group title="最近添加的项目">
       <cell title="项目1" is-link link="/project/1"></cell>
       <cell title="项目2" is-link link="/project/2"></cell>
     </group>
  </div>
</template>
<script>
  import { Search, XHeader, Group, Cell} from 'vux'

  export default {
    components: {
      Search,
      XHeader,
      Group,
      Cell
    },

    data () {
      return {
          value:"",
          results:[]
      }
    },

    methods: {
      getResult(val) {
        this.results = val ? getResult(this.value) : []
      },
      onSubmit() {

      },
      resultClick(){
        this.$router.replace('/project/'+"111")
      }
    },

    mounted() {

    }
  }

  function getResult (val) {
    let rs = []
    for (let i = 0; i < 20; i++) {
      rs.push({
        title: `${val} result: ${i + 1} `,
        other: i
      })
    }
    return rs
  }
</script>
